"""
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    created by lei.chang on '22/05/2023'
    comment: 基础数据
"""
from sqlalchemy import func
from sqlalchemy.dialects.mysql import VARCHAR, INTEGER, DATETIME, TIMESTAMP, BOOLEAN

from project.core.base import CustomModel, Column


class Component(CustomModel):
    """ 组件库
    """
    __tablename__ = "component"
    id = Column(INTEGER(unsigned=True), primary_key=True, autoincrement=True)
    name = Column(VARCHAR(30), nullable=False, server_default='', comment='组件名称')
    icon = Column(VARCHAR(200), nullable=False, server_default='', comment='组件图标')
    component_type = Column(VARCHAR(30), nullable=False, server_default='', comment='组件类型: display(展示)/input(录入)/submit(提交)')
    style = Column(VARCHAR(30), nullable=False, server_default='', comment='风格: text(文本)/button(按钮)/image(图片)/table(表格)/rich_text(富文本)/answer_result(对答结果)/input(输入框)/'
                                                                           'score(评分)/radio(下拉选择)/select_single(选择器-单选)/select_multiline(选择器-多选)/image_upload(图片上传)/plate_number(车牌号码)')
    remark = Column(VARCHAR(200), nullable=False, server_default='', comment='备注')
    rank = Column(INTEGER, nullable=False, server_default='0', comment='排序字段', is_displayed=False)
    create_time = Column(DATETIME, nullable=False, server_default=func.now(), is_displayed=False)
    update_time = Column(TIMESTAMP, nullable=False, server_default=func.now(), onupdate=func.now(), is_displayed=False)


class NodeType(CustomModel):
    """ 节点类型表
    """
    __tablename__ = "node_type"
    code = Column(VARCHAR(30), nullable=True, primary_key=True, comment='类型编号')
    name = Column(VARCHAR(30), nullable=False, server_default='', comment='类型名称')
    rank = Column(INTEGER, nullable=False, server_default='0', comment='排序字段', is_displayed=False)
    is_deleted = Column(BOOLEAN, nullable=False, server_default='0', comment='是否删除 0: 未删除 1: 已删除', is_displayed=False)
    create_time = Column(DATETIME, nullable=False, server_default=func.now(), is_displayed=False)
    update_time = Column(TIMESTAMP, nullable=False, server_default=func.now(), onupdate=func.now(), is_displayed=False)
